package com.xxgc.springboot.task;

import java.util.Timer;
import java.util.TimerTask;

/**
 * @program: springboot
 * @description:
 * @author: Mr.abel(ShiJiaYi)
 * @create: 2022-09-19 18:40
 **/
public class TimerTest {
    //Timer Java自带的定时任务类
    public static void main(String[] args) {
        //任务1
        TimerTask timerTask = new TimerTask(){
            public void run(){
                System.out.println("我被执行了");
            }
        };
        //计时器
        Timer timer = new Timer();
        //开始执行任务  1秒后执行  每3秒执行一次
        timer.schedule(timerTask,1000, 3000);
    }
}
